package com.example.demo.controller;

import com.example.demo.entity.TGdCommodityExtend;
import com.example.demo.service.TGdCommodityExtendService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 商城扩展表(TGdCommodityExtend)表控制层
 *
 * @author makejava
 * @since 2022-02-23 23:29:32
 */
@RestController
@RequestMapping("tGdCommodityExtend")
public class TGdCommodityExtendController {
    /**
     * 服务对象
     */
    @Resource
    private TGdCommodityExtendService tGdCommodityExtendService;



    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<TGdCommodityExtend> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.tGdCommodityExtendService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param tGdCommodityExtend 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<TGdCommodityExtend> add(TGdCommodityExtend tGdCommodityExtend) {
        return ResponseEntity.ok(this.tGdCommodityExtendService.insert(tGdCommodityExtend));
    }

    /**
     * 编辑数据
     *
     * @param tGdCommodityExtend 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<TGdCommodityExtend> edit(TGdCommodityExtend tGdCommodityExtend) {
        return ResponseEntity.ok(this.tGdCommodityExtendService.update(tGdCommodityExtend));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.tGdCommodityExtendService.deleteById(id));
    }

}

